#ifndef _ROOM_H_
#define _ROOM_H_

#include <list>
#include "Game.h"

namespace car
{

class Player;

typedef enum {
	RolePlayer,
	RoleMap
}RoleType;

typedef enum {
	RoomStateWaiting,
	RoomStateLoadingGame,
	RoomStateInGame,
	RoomStateGameEnd
}RoomState;

class Room
{
public:
	Room( void );
	Room( unsigned int roomId, unsigned char maxPlayerNumber );
	Room( unsigned int roomId, unsigned int hostId, unsigned char maxPlayerNumber );
	~Room( void );

	void			setRoomState( RoomState roomState )					{ mRoomState = roomState; }
	RoomState		getRoomState() const								{ return mRoomState; }
	void			setRoomId( unsigned int roomId )					{ mRoomId = roomId; }
	unsigned int	getRoomId() const									{ return mRoomId; }
	void			setHostId( unsigned int hostId )					{ mHostId = hostId; }
	unsigned int	getHostId() const									{ return mHostId; }
	void			setMaxPlayerNumber( unsigned char maxPlayerNum )	{ mMaxPlayerNumber = maxPlayerNum; }
	unsigned char	getMaxPlayerNumber() const							{ return mMaxPlayerNumber; }
	void			setNumForces( unsigned char numForces )				{ mNumForces = mNumForces; }
	unsigned char	getNumForces() const								{ return mNumForces; }

	unsigned char	getCurrentPlayerNumber()							{ return ( unsigned char )mPlayerList.size(); }
	void			setMapId( unsigned int mapId)						{ mMapId = mapId; }
	unsigned int	getMapId() const									{ return mMapId; }

	std::list<Player *> &	getPlayerList()	{ return mPlayerList; }
	bool	addPlayer( Player * player );
	bool	removePlayer( unsigned int playerId );
	void	clearPlayerList();
	bool	hasPlayer( unsigned int playerId );

	bool	startGame();
	void	stopGame();
	void	checkPlayerLoadingProgress();

	bool	spreadPacket( const unsigned char data[], int size );

	void	clearRoom();
	/*bool	operator==( const Room & room )
	{
		if( mRoomId == room.getRoomId() )
			return true;
		return false;
	}*/

private:
	RoomState		mRoomState;
	unsigned int	mRoomId;
	unsigned int	mHostId;
	unsigned char	mMaxPlayerNumber;
	unsigned char	mNumForces;
	std::list<Player *> mPlayerList;
	unsigned int	mMapId;
	Game			*mGame;
};

};
#endif

